//
//  PlayerDataTableViewCell.swift
//  FootballDataRecord
//
//  Created by Xx Jiang on 2020/1/8.
//  Copyright © 2020 Xx Jiang. All rights reserved.
//

import UIKit

//["射门":DHMatchDataShoot,"射正":DHMatchDataShootIn,"越位":DHMatchDataOffside,"角球":DHMatchDataCornnerKick,"犯规":DHMatchDataFoul,"红牌":DHMatchDataRedCard,"黄牌":DHMatchDataYellowCard,"进球":DHMatchDataDirveBall,"换人":DHMatchDataPlayerChangeTime]

class PlayerDataTableViewCell: UITableViewCell {
    @IBOutlet weak var playerNumAnName: UILabel!
    
    /// 角球
    @IBOutlet weak var cornerKick: UILabel!
    /// 犯规
    @IBOutlet weak var foul: UILabel!
    /// 越位
    @IBOutlet weak var offSide: UILabel!
    /// 射正
    @IBOutlet weak var shootIn: UILabel!
    /// 射门
    @IBOutlet weak var shoot: UILabel!
    /// 进球
    @IBOutlet weak var getScore: UILabel!
    /// 换上换下
    @IBOutlet weak var changeUpOrDown: UILabel!
    /// 红牌
    @IBOutlet weak var redCard: UIView!
    /// 黄牌2
    @IBOutlet weak var yellowcard2: UIView!
    /// 黄牌1
    @IBOutlet weak var yellowCard1: UIView!
    /// 首发
    @IBOutlet weak var shouFaLabel: UILabel!
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }
    
    func setCell(model:PlayerModel){
        self.playerNumAnName.text = "\(model.playerNum!)  \(model.playerName!)"
        if model.playerType == "0" {
            shouFaLabel.isHidden = false
        }else{
            shouFaLabel.isHidden = true
        }
        switch Int(model.matchInfo!.matchDataYellowCard ?? "0") {
        case 0:
            yellowCard1.isHidden = true
            yellowcard2.isHidden = true
            redCard.isHidden = true
            break
        case 1:
            yellowCard1.isHidden = false
            yellowcard2.isHidden = true
            redCard.isHidden = true
            break
        default:
            yellowCard1.isHidden = true
            yellowcard2.isHidden = true
            redCard.isHidden = false
        }
        if !DYStringIsEmpty(value: model.matchInfo!.matchDataPlayerChangeTime as AnyObject?){
            changeUpOrDown.isHidden = false
            if model.playerType == "0" {
                let dateModel = DateModel()
                dateModel.otherTime(model.matchInfo!.matchDataPlayerChangeTime!)
                changeUpOrDown.text = "\(dateModel.minute)'↓"
            }else{
                let dateModel = DateModel()
                dateModel.otherTime(model.matchInfo!.matchDataPlayerChangeTime!)
                changeUpOrDown.text = "\(dateModel.minute)'↑"
            }
        }else{
            changeUpOrDown.isHidden = true;
        }
        
        getScore.text = model.matchInfo!.matchDataDirveBall ?? "0"
        shoot.text = model.matchInfo!.matchDataShoot ?? "0"
        shootIn.text = model.matchInfo!.matchDataShootIn ?? "0"
        offSide.text = model.matchInfo!.matchDataOffside ?? "0"
        foul.text = model.matchInfo!.matchDataFoul ?? "0"
        cornerKick.text = model.matchInfo!.matchDataCornnerKick ?? "0"
        
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
}
